
var xmlhttp;
if (window.XMLHttpRequest){

    xmlhttp = new XMLHttpRequest();
}else{

    xmlhttp = new  ActiveXObject("Microsoft.XMLHTTP");
}

//定义回调函数
xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState === 4 && xmlhttp.status === 200){
        //news_content.innerHTML = xmlhttp.responseText;
        //JSON。parse（）把文本数据解析为jason对象
        showJson(JSON.parse(xmlhttp.responseText));

    }
}

//HTTP访问方法
xmlhttp.open("GET","top250.json",true);
xmlhttp.send();

function showJson(jsonData) {
    document.getElementById("title").innerText = jsonData.title;
    var tempHtml = "";
    for (var i = 0; i <10 ; i++ ){
        tempHtml += "<li>" + jsonData.subjects[i].title + "</li>\n";

    }
    document.getElementById("news_update_list").innerHTML = tempHtml;
}
